/*
 *
 * This file is part of the open-source SeetaFace engine, which includes three modules:
 * SeetaFace Detection, SeetaFace Alignment, and SeetaFace Identification.
 *
 * This file is part of the SeetaFace Detection module, containing codes implementing the
 * face detection method described in the following paper:
 *
 *
 *   Funnel-structured cascade for multi-view face detection with alignment awareness,
 *   Shuzhe Wu, Meina Kan, Zhenliang He, Shiguang Shan, Xilin Chen.
 *   In Neurocomputing (under review)
 *
 *
 * Copyright (C) 2016, Visual Information Processing and Learning (VIPL) group,
 * Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China.
 *
 * The codes are mainly developed by Shuzhe Wu (a Ph.D supervised by Prof. Shiguang Shan)
 *
 * As an open-source face recognition engine: you can redistribute SeetaFace source codes
 * and/or modify it under the terms of the BSD 2-Clause License.
 *
 * You should have received a copy of the BSD 2-Clause License along with the software.
 * If not, see < https://opensource.org/licenses/BSD-2-Clause>.
 *
 * Contact Info: you can send an email to SeetaFace@vipl.ict.ac.cn for any problems.
 *
 * Note: the above information must be kept whenever or wherever the codes are used.
 *
 */

#ifndef SEETA_FD_FUST_H_
#define SEETA_FD_FUST_H_

//#include <algorithm>
//#include <memory>
//#include <string>


#include "classifier.h"
#include "detector.h"
#include "feature_map.h"
#include "model_reader.h"
//#include "classifier/lab_boosted_classifier.h"
#include "lab_boost_model_reader.h"
#include "lab_feature_map.h"
#include "surf_mlp.h"
//namespace seeta {
//namespace fd {
typedef struct Argument{
	int Pic_width;
	int Pic_height;
	int step_x_;
	int step_y_;
	int wnd_size_;
	int32_t* int_img;
	uint32_t* square_int_img;
	int base_class_size;
	int FeatSize;
	int wnd_width;
	int wnd_height;
	float scale_factor;
	float* base_weights[ModelNum];
	float* base_threshold[ModelNum];
	int32_t* feat_x[ModelNum];
	int32_t* feat_y[ModelNum];
};
typedef struct classFuStDetector FuStDetector;
struct classFuStDetector {
  int32_t wnd_size_;
  int32_t slide_wnd_step_x_;
  int32_t slide_wnd_step_y_;

  int32_t num_hierarchy_;
  int32_t hierarchy_size_[3];
  int32_t num_stage_[5];
  int32_t* wnd_src_id_[5];// [3];

  uint8_t* wnd_data_buf_;
  uint8_t* wnd_data_;

  LABBoostedClassifier  labmodel_[3];
  LABFeatureMap lab_feat_map_;
  SURFMLP surfmodel_[3];
  SURFFeatureMap surf_feat_map_;
  //std::map<ClassifierType, int32_t> cls2feat_idx_;
  int32_t cls2feat_idx_[2][1];

  //DISABLE_COPY_AND_ASSIGN(FuStDetector);
};

void ReleaseFustDetector(struct classFuStDetector *p);
bool FuStDetectorLoadModel(struct classFuStDetector *p,const char* model_path);
FaceInfo* FuStDetectorDetect(struct classFuStDetector *p, ImagePyramid* img_pyramid, FDHandle* handle, int *pos_wndLen);
LABBoostModelReader FuStDetectorCreateModelReader(struct classFuStDetector *p, int type);
void* FuStDetectorCreateClassifier(struct classFuStDetector *p, int type);
LABFeatureMap FuStDetectorCreateFeatureMap(struct classFuStDetector *p, int type);
void FuStDetectorGetWindowData(struct classFuStDetector *p, const ImageData  img, const Rect  wnd,FDHandle* handle);

//void InitFuStDetector(struct classFuStDetector *p, int wnd_size = 40, int slide_wnd_step_x = 4, int slide_wnd_step_y = 4, int num_hierarchy = 0);
void InitFuStDetector(struct classFuStDetector *p, int wnd_size , int slide_wnd_step_x , int slide_wnd_step_y , int num_hierarchy );
void FuStDetectorSetWindowSize(struct classFuStDetector *p, int32_t size);

void FuStDetectorSetSlideWindowStep(struct classFuStDetector *p, int32_t step_x, int32_t step_y);
#endif  // SEETA_FD_FUST_H_
